home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / mac / files / t_sys5 / 92052tar.gz / 920528.tar / icmp.h < prev    next >
C/C++ Source or Header  |  1992-01-08  |  6KB  |  160 lines

  1. /* @(#) $Header: icmp.h,v 1.6 92/01/08 13:45:12 deyke Exp $ */
  2.  
  3. #ifndef _ICMP_H
  4. #define _ICMP_H
  5.  
  6. #ifndef _GLOBAL_H
  7. #include "global.h"
  8. #endif
  9.  
  10. #ifndef _MBUF_H
  11. #include "mbuf.h"
  12. #endif
  13.  
  14. #ifndef _IFACE_H
  15. #include "iface.h"
  16. #endif
  17.  
  18. #ifndef _INTERNET_H
  19. #include "internet.h"
  20. #endif
  21.  
  22. #ifndef _IP_H
  23. #include "ip.h"
  24. #endif
  25.  
  26. #ifndef _SESSION_H
  27. #include "session.h"
  28. #endif
  29.  
  30. #ifndef _TIMER_H
  31. #include "timer.h"
  32. #endif
  33.  
  34. /* SNMP MIB variables, used for statistics and control. See RFC 1066 */
  35. extern struct mib_entry Icmp_mib[];
  36. #define icmpInMsgs              Icmp_mib[1].value.integer
  37. #define icmpInErrors            Icmp_mib[2].value.integer
  38. #define icmpInDestUnreachs      Icmp_mib[3].value.integer
  39. #define icmpInTimeExcds         Icmp_mib[4].value.integer
  40. #define icmpInParmProbs         Icmp_mib[5].value.integer
  41. #define icmpInSrcQuenchs        Icmp_mib[6].value.integer
  42. #define icmpInRedirects         Icmp_mib[7].value.integer
  43. #define icmpInEchos             Icmp_mib[8].value.integer
  44. #define icmpInEchoReps          Icmp_mib[9].value.integer
  45. #define icmpInTimestamps        Icmp_mib[10].value.integer
  46. #define icmpInTimestampReps     Icmp_mib[11].value.integer
  47. #define icmpInAddrMasks         Icmp_mib[12].value.integer
  48. #define icmpInAddrMaskReps      Icmp_mib[13].value.integer
  49. #define icmpOutMsgs             Icmp_mib[14].value.integer
  50. #define icmpOutErrors           Icmp_mib[15].value.integer
  51. #define icmpOutDestUnreachs     Icmp_mib[16].value.integer
  52. #define icmpOutTimeExcds        Icmp_mib[17].value.integer
  53. #define icmpOutParmProbs        Icmp_mib[18].value.integer
  54. #define icmpOutSrcQuenchs       Icmp_mib[19].value.integer
  55. #define icmpOutRedirects        Icmp_mib[20].value.integer
  56. #define icmpOutEchos            Icmp_mib[21].value.integer
  57. #define icmpOutEchoReps         Icmp_mib[22].value.integer
  58. #define icmpOutTimestamps       Icmp_mib[23].value.integer
  59. #define icmpOutTimestampReps    Icmp_mib[24].value.integer
  60. #define icmpOutAddrMasks        Icmp_mib[25].value.integer
  61. #define icmpOutAddrMaskReps     Icmp_mib[26].value.integer
  62. #define NUMICMPMIB      26
  63.  
  64. /* Internet Control Message Protocol */
  65.  
  66. /* Message types */
  67. #define ICMP_ECHO_REPLY         0       /* Echo Reply */
  68. #define ICMP_DEST_UNREACH       3       /* Destination Unreachable */
  69. #define ICMP_QUENCH             4       /* Source Quench */
  70. #define ICMP_REDIRECT           5       /* Redirect */
  71. #define ICMP_ECHO               8       /* Echo Request */
  72. #define ICMP_TIME_EXCEED        11      /* Time-to-live Exceeded */
  73. #define ICMP_PARAM_PROB         12      /* Parameter Problem */
  74. #define ICMP_TIMESTAMP          13      /* Timestamp */
  75. #define ICMP_TIME_REPLY         14      /* Timestamp Reply */
  76. #define ICMP_INFO_RQST          15      /* Information Request */
  77. #define ICMP_INFO_REPLY         16      /* Information Reply */
  78. #define ICMP_ADDR_MASK          17      /* Address mask request */
  79. #define ICMP_ADDR_MASK_REPLY    18      /* Address mask reply */
  80. #define ICMP_TYPES              19
  81.  
  82. /* Internal format of an ICMP header (checksum is missing) */
  83. struct icmp {
  84.     char type;
  85.     char code;
  86.     union icmp_args {
  87.         int16 mtu;
  88.         int32 unused;
  89.         unsigned char pointer;
  90.         int32 address;
  91.         struct {
  92.             int16 id;
  93.             int16 seq;
  94.         } echo;
  95.     } args;
  96. };
  97. #define ICMPLEN         8       /* Length of ICMP header on the net */
  98. #define NULLICMP        (union icmp_args *)0
  99.  
  100. /* Destination Unreachable codes */
  101. #define ICMP_NET_UNREACH        0       /* Net unreachable */
  102. #define ICMP_HOST_UNREACH       1       /* Host unreachable */
  103. #define ICMP_PROT_UNREACH       2       /* Protocol unreachable */
  104. #define ICMP_PORT_UNREACH       3       /* Port unreachable */
  105. #define ICMP_FRAG_NEEDED        4       /* Fragmentation needed and DF set */
  106. #define ICMP_ROUTE_FAIL         5       /* Source route failed */
  107. #define ICMP_ADMIN_PROHIB       13      /* Administrativly prohibbited */
  108.  
  109. #define NUNREACH        14
  110.  
  111. /* Time Exceeded codes */
  112. #define ICMP_TTL_EXCEED         0       /* Time-to-live exceeded */
  113. #define ICMP_FRAG_EXCEED        1       /* Fragment reassembly time exceeded */
  114.  
  115. #define NEXCEED         2
  116.  
  117. /* Redirect message codes */
  118. #define ICMP_REDR_NET   0       /* Redirect for the network */
  119. #define ICMP_REDR_HOST  1       /* Redirect for the host */
  120. #define ICMP_REDR_TOS   2       /* Redirect for Type of Service, or-ed with prev */
  121.  
  122. #define NREDIRECT       3
  123.  
  124. extern int Icmp_trace;
  125.  
  126. struct ping {
  127.     struct ping *next;      /* Linked list pointers */
  128.     struct ping *prev;
  129.     int32 target;           /* Starting target IP address */
  130.     int32 sent;             /* Total number of pings sent */
  131.     int32 srtt;             /* Smoothed round trip time */
  132.     int32 mdev;             /* Mean deviation */
  133.     int32 responses;        /* Total number of responses */
  134.     struct timer timer;     /* Ping interval timer */
  135.     int16 len;              /* Length of data portion of ping */
  136. };
  137. /* ICMP messages, decoded */
  138. extern char *Icmptypes[],*Unreach[],*Exceed[],*Redirect[];
  139.  
  140. struct icmplink {
  141.     char proto;
  142.     void (*funct) __ARGS((int32,int32,int32,int,int,struct mbuf **));
  143. };
  144. extern struct icmplink Icmplink[];
  145.  
  146. /* In icmp.c: */
  147. void icmp_input __ARGS((struct iface *iface,struct ip *ip,struct mbuf *bp,
  148.     int rxbroadcast));
  149. int icmp_output __ARGS((struct ip *ip,struct mbuf *data,int type,int code,
  150.     union icmp_args *args));
  151.  
  152. /* In icmpcmd.c: */
  153. void echo_proc __ARGS((int32 source,int32 dest,struct icmp *icmp,struct mbuf *bp));
  154.  
  155. /* In icmphdr.c: */
  156. struct mbuf *htonicmp __ARGS((struct icmp *icmp,struct mbuf *data));
  157. int ntohicmp __ARGS((struct icmp *icmp,struct mbuf **bpp));
  158.  
  159. #endif  /* _ICMP_H */
  160.